package edu.cug.water.visual.modules.dataset.controller;

import edu.cug.water.visual.common.utils.PageUtils;
import edu.cug.water.visual.common.utils.R;
import edu.cug.water.visual.modules.dataset.entity.DatasetLogEntity;
import edu.cug.water.visual.modules.dataset.service.DatasetLogService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;




/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2021-10-30 19:31:57
 */
@RestController
@RequestMapping("generator/datasetlog")
public class DatasetLogController {
    @Autowired
    private DatasetLogService datasetLogService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:datasetlog:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = datasetLogService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{logId}")
    @RequiresPermissions("generator:datasetlog:info")
    public R info(@PathVariable("logId") Long logId){
		DatasetLogEntity datasetLog = datasetLogService.getById(logId);

        return R.ok().put("datasetLog", datasetLog);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:datasetlog:save")
    public R save(@RequestBody DatasetLogEntity datasetLog){
		datasetLogService.save(datasetLog);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:datasetlog:update")
    public R update(@RequestBody DatasetLogEntity datasetLog){
		datasetLogService.updateById(datasetLog);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:datasetlog:delete")
    public R delete(@RequestBody Long[] logIds){
		datasetLogService.removeByIds(Arrays.asList(logIds));

        return R.ok();
    }

}
